﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Размерность монитора текущего пользователя
/// </summary>
public class ScreenValues
{    
    private const string H_Key = "H_Key";
    private const string W_Key = "W_Key";
    private const int Def_H = 768;
    private const int Def_W = 1024;
    
    /// <summary>
    /// Размерность монитора текущего пользователя
    /// </summary>
    public ScreenValues(int H_, int W_)
    {
        H = H_;
        W = W_;
    }
    public ScreenValues()
    {   
    }
    public int H 
    {
        get 
        {
            if (null != HttpContext.Current.Request.Cookies[H_Key])
                return Convert .ToInt16( HttpContext.Current.Request.Cookies[H_Key].Value);
            return Def_H;
        }
        set
        {
            HttpCookie _H = new HttpCookie(H_Key, value.ToString () );         
            if (null == HttpContext.Current.Response.Cookies[H_Key])
                HttpContext.Current.Response.AppendCookie(_H);
            else
                HttpContext.Current.Response.SetCookie(_H);
        }
    }
    public int W
    {
        get
        {
            if (null != HttpContext.Current.Request.Cookies[W_Key])
                return Convert.ToInt16(HttpContext.Current.Request.Cookies[W_Key].Value);
            return Def_W;
        }
        set
        {
            HttpCookie _W = new HttpCookie(W_Key, value.ToString());
            if (null == HttpContext.Current.Response.Cookies[W_Key])
                HttpContext.Current.Response.AppendCookie(_W);
            else
                HttpContext.Current.Response.SetCookie(_W);
        }
    }
    
    public int GetRecordsOnScreen(int Record_H)
    {
        return Convert.ToInt16(H / Record_H); 
    }

}
